package cn.org.custom.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class InboundHandlerAdapter extends ChannelInboundHandlerAdapter {
    // 接收响应消息
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        new ReadHandlerAdapter().read(ctx, msg);
    }

    // 在连接建立后触发 active 事件
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        new ActiveAdapter().active(ctx);
    }

    // 在连接断开时触发
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        new InActiveAdapter().inActive(ctx);
    }

    // 在出现异常时触发
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        new ExceptionCaughtAdapter().caught(ctx, cause);
    }
}
